from launch import LaunchDescription
from launch_ros.actions import Node
#封装终端指令相关类--------------
#from launch.actions import ExecuteProcess
#from launch.substitutions import FindExecutable
#参数声明与获取-----------------
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
#文件包含相关-------------------
#from launch.actions import IncludeLaunchDescription
#from launch.launch_description_sources import PythonLaunchDescriptionSource
#分组相关----------------------
#from launch_ros.actions import PushRosNamespace
#from launch.actions import GroupAction
#事件相关----------------------
#from launch.event_handlers import OnProcessStart,OnProcessExit
#from launch.actions import ExecuteProcess,RegisterEventHandler,LogInfo
#获取功能包下share目录路径-------
#from ament_index_python.packages import get_package_share_directory

def generate_launch_description():
    #1.声明一个launch参数，default_value是一个字符串 因为要用到命令行的拼接。
    #2.把在个参数的键赋给程序中的某个参数
    # parameter的值要么是个字典数组，要么是一个config路径

    bg_r=DeclareLaunchArgument("backg_r",default_value="255")
    bg_g=DeclareLaunchArgument("backg_g",default_value="255")
    bg_b=DeclareLaunchArgument("backg_b",default_value="255")
    t1=Node(
        package="turtlesim",
        executable="turtlesim_node",
        parameters=[{"background_r":LaunchConfiguration("backg_r"),
                     "background_g":LaunchConfiguration("backg_g"),
                     "background_b":LaunchConfiguration("backg_b")}]
        #ros2 launch cpp01_launch py04_args_launch.py backg_r:=100
    )
    

    return LaunchDescription([bg_r,bg_g,bg_b,t1])